---
title: Neon Postgres
---

Neon is a fully managed serverless PostgreSQL database. It separates storage and compute to offer
features such as instant branching and automatic scaling.

With the `pgvector` extension, Neon provides a vector store that can be used with LangChain.js to store and query embeddings.

## Setup

### Select a Neon project

If you do not have a Neon account, sign up for one at [Neon](https://neon.tech). After logging into the Neon Console, proceed
to the [Projects](https://console.neon.tech/app/projects) section and select an existing project or create a new one.

Your Neon project comes with a ready-to-use Postgres database named `neondb` that you can use to store embeddings. Navigate to
the Connection Details section to find your database connection string. It should look similar to this:

```text
postgres://alex:AbC123dEf@ep-cool-darkness-123456.us-east-2.aws.neon.tech/dbname?sslmode=require
```

Keep your connection string handy for later use.

### Application code

To work with Neon Postgres, you need to install the `@neondatabase/serverless` package which provides a JavaScript/TypeScript
driver to connect to the database.

```bash npm
npm install @neondatabase/serverless
```
import IntegrationInstallTooltip from '/snippets/javascript-integrations/integration-install-tooltip.mdx';

<IntegrationInstallTooltip/>

```bash npm
npm install @langchain/community @langchain/core
```
To initialize a `NeonPostgres` vectorstore, you need to provide your Neon database connection string. You can use the connection string
we fetched above directly, or store it as an environment variable and use it in your code.

```typescript
const vectorStore = await NeonPostgres.initialize(embeddings, {
  connectionString: NEON_POSTGRES_CONNECTION_STRING,
});
```

## Usage

import Example from "/snippets/javascript-integrations/examples/indexes/vector_stores/neon/example.mdx";

<Example />

## Related

- Vector store [conceptual guide](/oss/concepts/#vectorstores)
- Vector store [how-to guides](/oss/how-to/#vectorstores)
